﻿@model  Zatify.WebUI.Models.UserProfileBusinessesDealsViewModel
@{
    ViewBag.Title = "Deals";
    ViewBag.ContentTitle = "Deals";
    Layout = "~/Views/Shared/_ContentLayoutWithPaging.cshtml";
}
@section ContentTitleButton
{
    <a href="@Url.Action("DealsMap", "UserProfile", new { page = "Deals" }, "http")" class="red_btn" style="float: right;">
        Map</a>
}
<div class="deal_display">
    <table width = "100%" cellpadding = "0" cellspacing = "10" border="0">
        @for (int i = 0; i < Model.Promotions.Count; i++)
        {
            if ((i + 1) % 3 == 1)
            {
                @:<tr>
            }

            <td class="deal_display_td">
            <a href="@Url.Action("PromotionDetails", new { id = Model.Promotions[i].PromotionId })" class="deal_display_a">
                <div style="width: 298px; height: 180px; text-align: center;
                background:url('@Url.Action("GetPromotionPhoto", "UserProfile", new { promotionId = Model.Promotions[i].PromotionId, w = 298, h = 170 })') no-repeat scroll center center transparent">
                </div>
                <div class="deal_thumb_content">
                    <h4>
                        @(i + 1). @Model.Promotions[i].Business.BusinessName</h4>
                    <div class="rating_price">
                        @InlineHelpers.FiveStarsRatingReadonly(Model.Promotions[i].Business.Rating)
                        <span class="rating_text">
                            @Model.Promotions[i].Business.ReviewsCount Reviews</span>
                        <div class="thumb_price">
                            $$</div>
                    </div>
                    <p class="gold">
                        @if (!String.IsNullOrEmpty(Model.Promotions[i].Business.StreetAddress1))
                        {
                            @InlineHelpers.TrimText(Model.Promotions[i].Business.StreetAddress1, 35)
                        }
                        else
                        {
                            <text>&nbsp;</text> 
                        }</p>
                    <p class="gray">
                        @if (Model.Promotions[i].Business.Distance.HasValue)
                        { 
                            @Model.Promotions[i].Business.Distance.Value.ToString("0.00")<text> mi</text>
                        }
                        else
                        {
                            <text>N/A</text>
                        }
                    </p>
                    <p class="gray">
                        @if (Model.Promotions[i].Categories != null && Model.Promotions[i].Categories.Count() > 0)
                        {
                            @InlineHelpers.TrimText(InlineHelpers.BusinessCategories(Model.Promotions[i].Categories).ToString(), 35)
                        }
                        else
                        {
                            <text>&nbsp;</text> 
                        }
                    </p>
                    <p class="deal_price">
                        @if (!String.IsNullOrEmpty(Model.Promotions[i].PromotionText))
                        {
                            @Model.Promotions[i].PromotionText    
                        }
                        else
                        {
                            <text>&nbsp;</text> 
                        }
                    </p>
                </div>
            </a>
            </td>
            
            if (i == Model.Promotions.Count - 1)
            {
                for (int j = 0; j < 3 - ((i + 1) % 3); ++j)
                {
                    <td></td>
                }
            }
                
            if ((i == Model.Promotions.Count - 1) || ((i + 1) % 3 == 0))
            {
                @:</tr>
            }
        }
    </table>
</div>
@section Paging
{
    @Html.Pager(Model.PagingInfo, x => Url.Action("Deals", new { page = x }), 3)
}
